<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<a href="addBrand2.html"><input type="button" value="新增"></a><br>
<hr>

    <script src="js/axios-0.18.0.js"></script>
<script src="js/vue.js"></script>

<div id="add" >
    <table  border="1" cellspacing="0" width="100%" >
        <tr>
          <th>序号</th>
          <th>品牌名称</th>
          <th>企业名称</th>
          <th>排序</th>
          <th>品牌介绍</th>
          <th>状态</th>
          <th>操作</th>
        </tr>

        <tr align="center" v-for="(brand,i) in brands">
            <td>{{i+1}}</td>
            <td>{{brand.brandName}}</td>
            <td>{{brand.companyName}}</td>
            <td>{{brand.ordered}}</td>
            <td>{{brand.description}}</td>
            <td>{{brand.status}}</td>
            <td></td>
        </tr>
    </table>
</div>

    <script>
        new Vue({
            el:"#add",
            data:{
              brands:""
            },
            mounted(){
                var _this= this;
                axios({
                            method: "post",
                            url: "http://localhost:8080/brand-demo2/selectAll"
                        }).then(function (resp) {
                    _this.brands = resp.data;
                })
            },

        })

/*        window.onload=function () {
            axios({
                method: "post",
                url: "http://localhost:8080/brand-demo2/selectAll"
            }).then(function (resp) {
                resp.data;


                let brands = resp.data;

                var str = "    <tr>\n" +
                    "        <th>序号</th>\n" +
                    "        <th>品牌名称</th>\n" +
                    "        <th>企业名称</th>\n" +
                    "        <th>排序</th>\n" +
                    "        <th>品牌介绍</th>\n" +
                    "        <th>状态</th>\n" +
                    "        <th>操作</th>\n" +
                    "    </tr>";

                for (let i = 0; i < brands.length; i++) {
                    let brand = brands[i];
                    str += "    <tr align=\"center\">\n" +
                        "        <td>1</td>\n" +
                        "        <td>" + brand.brandName + "</td>\n" +
                        "        <td>" + brand.companyName + "</td>\n" +
                        "        <td>" + brand.ordered + "</td>\n" +
                        "        <td>" + brand.description + "</td>\n" +
                        "        <td>" + brand.status + "</td>\n" +
                        "        <td><a href=\"#\">修改</a> <a href=\"#\">删除</a></td>\n" +
                        "    </tr>"
                }

                document.getElementById("brandTable").innerHTML = str;

            })
        }*/


    </script>

</body>
</html>